﻿using System;
using Autodesk.Revit.DB;

namespace YArchitech.Temp
{
	public static class GeUtils
	{
		public static double Area_Rectangular(double w, double h)
		{
			return w * h;
		}

		public static double Circumference_Rectangular(double w, double h)
		{
			return 2.0 * (w + h);
		}

		public static double Area_Round(double diameter)
		{
			return Math.PI * diameter * diameter / 4.0;
		}

		public static double Circumference_Round(double diameter)
		{
			return Math.PI * diameter;
		}

		public static double Diameter(double area)
		{
			return 2.0 * Math.Sqrt(area / Math.PI);
		}

		public static double Circumference_Oval(double longAxis, double shortAxis)
		{
			return Math.PI * shortAxis + 2.0 * (longAxis - shortAxis);
		}

		public static double Area_Oval(double longAxis, double shortAxis)
		{
			return GeUtils.Area_Round(shortAxis) + GeUtils.Area_Rectangular(longAxis - shortAxis, shortAxis);
		}

		public static double RToD(double r)
		{
			return r * 57.295779513082323;
		}

		public static double DToR(double d)
		{
			return d * 0.017453292519943295;
		}

		public static bool IsParallel(XYZ vec1, XYZ vec2)
		{
			return vec1.CrossProduct(vec2).GetLength() < 0.001;
		}

		public static bool IsVertical(XYZ vec1, XYZ vec2)
		{
			return vec1.DotProduct(vec2) < 0.001;
		}

		public const double PI = Math.PI;

		public const double HalfPI = Math.PI*.5;

		public const double DegToRad = 0.017453292519943295;

		public const double RadToDeg = 57.295779513082323;
	}
}
